package ext

import com.android.build.api.dsl.CommonExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies

/**
 * Configure Compose-specific options
 */
internal fun Project.configureAndroidCompose(
    commonExtension: CommonExtension<*, *, *, *, *, *>,
) {
    commonExtension.apply {

        buildFeatures {
            compose = true
        }

        composeOptions {
            kotlinCompilerExtensionVersion = conf.appComposeCompilerVersion
        }

        dependencies {
            val bomPlatform = platform("androidx.compose:compose-bom:${libs.findVersion("compose-bom").get()}")

            add("androidTestImplementation", bomPlatform)
            add("debugImplementation", libs.findLibrary("androidx-compose-ui-ui-tooling").get())

            add("implementation", bomPlatform)
            add("implementation", libs.findBundle("androidx-compose").get())
            add("implementation", libs.findBundle("androidx-compose").get())
            add("implementation", libs.findLibrary("androidx-compose-ui-ui-tooling-preview").get())
            add("implementation", libs.findBundle("accompanist").get())

            add("implementation", libs.findLibrary("koin-androidx-compose").get())
            add("implementation", libs.findLibrary("coil-compose").get())
            add("implementation", libs.findLibrary("androidx-lifecycle-runtime-compose").get())
            add("implementation", libs.findLibrary("androidx-lifecycle-viewmodel-compose").get())

//            add("implementation", libs.findLibrary("compose-hooks").get())

        }

        testOptions {
            unitTests {
                // For Robolectric
                isIncludeAndroidResources = true
            }
        }

    }

}
